import { App } from 'vue'

export default (app: App) => {
  /**
   * @description 禁止按键重复点击
   */
  app.directive('disReClick', (el, binding) => {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true
        el.classList.add('is-disabled')
        setTimeout(() => {
          el.classList.remove('is-disabled')
          el.disabled = false
        }, binding.value || 3000)
      }
    })
  })
}
